using System;

namespace DuplexTransformers
{
    public class LiteTransformer<TLeft, TRight> : ITransformer<TLeft, TRight>
    {
        private readonly Func<TLeft, TRight> _leftFunc;
        private readonly Func<TRight, TLeft> _rightFunc;

        public LiteTransformer(Func<TLeft, TRight> leftFunc, Func<TRight, TLeft> rightFunc)
        {
            _leftFunc = leftFunc;
            _rightFunc = rightFunc;
        }

        public TRight Invoke(TLeft src, TRight ignored)
        {
            return _leftFunc.Invoke(src);
        }

        public TLeft Invoke(TRight src, TLeft ignored)
        {
            return _rightFunc.Invoke(src);
        }
    }
//    public class LiteTransformer<TLeft, TRight> : ITransformer<TLeft, TRight>
//    {
//        private readonly Func<TLeft, TRight, TRight> _leftFunc;
//        private readonly Func<TRight, TLeft, TLeft> _rightFunc;
//
//        public LiteTransformer(Func<TLeft, TRight, TRight> leftFunc, Func<TRight, TLeft, TLeft> rightFunc)
//        {
//            _leftFunc = leftFunc;
//            _rightFunc = rightFunc;
//        }
//
//        public TRight Invoke(TLeft src, TRight current)
//        {
//            return _leftFunc.Invoke(src, current);
//        }
//
//        public TLeft Invoke(TRight src, TLeft current)
//        {
//            return _rightFunc.Invoke(src, current);
//        }
//    }
}